package coder.nav.controller;

import coder.nav.common.JwtToken;
import coder.nav.common.R;
import coder.nav.model.bo.NavSaveSettingBO;
import coder.nav.model.vo.setting.NavCodeMirrorHintVO;
import coder.nav.model.vo.setting.NavIdeSettingVO;
import coder.nav.model.vo.setting.NavMemoSettingVO;
import coder.nav.model.vo.setting.NavSettingVO;
import coder.nav.service.NavSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "个人设置")
@RestController
@RequestMapping("/setting")
public class NavSettingController {

    @Autowired
    private NavSettingService settingService;

    @JwtToken
    @ApiOperation("个人设置-列表")
    @GetMapping("/getSettingList")
    public R<List<NavSettingVO>> getSettingList() {
        return new R<>(settingService.getSettingList());
    }

    @JwtToken
    @ApiOperation("个人设置-保存")
    @PostMapping("/saveSetting")
    public R<Void> saveSetting(@RequestBody NavSaveSettingBO bo) {
        settingService.saveSetting(bo);
        return new R<>();
    }

    @JwtToken
    @ApiOperation("获取编辑器默认配置")
    @GetMapping("/getIdeSetting")
    public R<NavIdeSettingVO> getIdeSetting() {
        return new R<>(settingService.getIdeSetting());
    }

    @JwtToken
    @ApiOperation("获取记事本默认配置")
    @GetMapping("/getMemoSetting")
    public R<NavMemoSettingVO> getMemoSetting() {
        return new R<>(settingService.getMemoSetting());
    }

    @JwtToken
    @ApiOperation("获取代码补全配置")
    @GetMapping("/getHintSetting")
    public R<List<NavCodeMirrorHintVO>> getHintSetting(@RequestParam("lang") String lang) {
        return new R<>(settingService.getHintSetting(lang));
    }

}
